/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo;

/**
 *
 * @author TQNINH
 */
class NamedThread extends Thread {
    String name;
    
    public void run(){
        int count = 0;
        while(count <= 3) {
            System.out.println(Thread.activeCount());
            
            name = Thread.currentThread().getName();
            count++;
            System.out.println(name);
            if(name.equals("Thread1")){
                System.out.println("Marimba");
            }else{
                System.out.println("Jini");
            }
        }
    }
}

public class MyThead {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        NamedThread objNamedThread = new NamedThread();
        objNamedThread.setName("Thread1");
        
        System.out.println(Thread.currentThread().isAlive());
        System.out.println(objNamedThread.isAlive());
        
        objNamedThread.start();
        System.out.println(Thread.currentThread().isAlive());
        System.out.println(objNamedThread.isAlive());
    }
}
